package com.pitaya.winwine.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "tb_tag")
public class Tag implements Serializable {
	
	private static final long serialVersionUID = -3110316698642627210L;
	
	@Id @GeneratedValue
	private Integer id;
	private Integer type;
	private String name;
	
	@ManyToMany(cascade = CascadeType.REFRESH, mappedBy = "tags", fetch = FetchType.LAZY)
	private Set<User> users;
	
	@ManyToMany(cascade = CascadeType.REFRESH, mappedBy = "tags", fetch = FetchType.LAZY)
	private Set<Topic> topics;
	
	@Transient
	private Long count;
	
	public Tag() {}
	public Tag(Integer id) {
		this.setId(id);
	}
	public Tag(Integer id, String name) {
		this.setId(id);
		this.setName(name);
	}
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Set<User> getUsers() {
		return users;
	}
	public void setUsers(Set<User> users) {
		this.users = users;
	}
	public Set<Topic> getTopics() {
		return topics;
	}
	public void setTopics(Set<Topic> topics) {
		this.topics = topics;
	}
	public Long getCount() {
		return count;
	}
	public void setCount(Long count) {
		this.count = count;
	}
}
